import axios from "axios";
import { Toast } from "vant";
const instance = axios.create({
  baseURL: "http://121.199.64.192:3000",
  timeout: 1000,
});
const http = {
  get(url, params) {
    return new Promise((resolve) => {
      return instance
        .get(url, {
          params: params,
        })
        .then((response) => {
          if (response.data.status === 0) {
            resolve(response);
          }
        })
        .catch((error) => {
          Toast(error.message);
        });
    });
  },
  post(url, params) {
    return new Promise((resolve) => {
      return instance
        .post(url, params)
        .then((response) => {
          if (response) {
            resolve(response);
          }
        })
        .catch((error) => {
          Toast(error.message);
        });
    });
  },
};
export default http;
